#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
int n{0}, tmp{0}, a[103];
vector<int> v;
int dp(int i);


int main()
{
    int s1, s2;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        v.push_back(tmp);
    }
    memset(a, 0, sizeof(a));  // 从i向后,能够拿到最多的
    if(n == 1) cout << v[0] << endl;
    else if(n == 2)
    {
        if(v[1] > v[0]) cout << v[1] << endl;
        else cout << v[0] << endl;
    }
    else if(n == 3)
    {
        a[n-1] = v[n-1];
        a[n-2] = v[n-2];
        a[n-3] = v[n-1] + v[n-3];
        if(a[n-3] > a[n-2]) cout << a[n-3] << endl;
        else cout << a[n-2] << endl;
    }
    else
    {
        a[n-1] = v[n-1];
        a[n-2] = v[n-2];
        a[n-3] = v[n-1] + v[n-3];
        for(int j = n-4; j >= 0; j--)
        {
            s1 = v[j] + a[j+2];  // 当前拿到的，加上之后能够拿到的最多的
            s2 = v[j+1] + a[j+3];
            if(s1 > s2) a[j] = s1;
            else a[j] = s2;
        }
        if(a[0] > a[1]) cout << a[0] << endl;
        else cout << a[1] << endl;
    }
    return 0; 
}
